home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
p4
/
p4-1_2b.lha
/
p4-1.2b
/
usc
/
usc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-01-25
|
3KB
|
176 lines
/*
* USC.C (Source file for the Microsecond Clock package)
*
* Written by: Arun Nanda (07/17/91)
* Modified by R. Butler
*/
#include "usc_sys.h"
VOID usc_init()
{
#if defined(MULTIMAX)
usc_multimax_timer = timer_init();
usc_MD_rollover_val = (usc_time_t) ((1<<usc_MD_timer_size)-1);
#endif
#if defined(SYMMETRY) || defined(SYMMETRY_PTX)
unsigned long roll;
usclk_init();
roll = 1 << (usc_MD_timer_size-1);
usc_MD_rollover_val = (usc_time_t) (roll + roll - 1);
#endif
#if defined(TC_2000) || defined(TC_2000_TCMP)
unsigned long roll;
roll = 1 << (usc_MD_timer_size-1);
usc_MD_rollover_val = (usc_time_t) (roll + roll - 1);
#endif
#if defined(IPSC860)
esize_t hwtime;
unsigned long ustime;
hwtime.shigh = hwtime.slow = ~0x0;
hwtime.shigh = (hwtime.shigh & 0x7) << (sizeof(long)*8-3);
hwtime.slow = ((hwtime.slow >> 3) & ~(0x7 << (sizeof(long)*8-3)))
| hwtime.shigh;
ustime = (unsigned long)hwtime.slow * 0.8;
usc_MD_rollover_val = (usc_time_t) ustime;
#endif
#if defined(NCUBE)
unsigned long roll;
roll = 1 << (usc_MD_timer_size-1);
usc_MD_rollover_val = (usc_time_t) (roll + roll - 1);
#endif
#if defined(FX2800) || defined(FX2800_SWITCH)
struct hrcval temptime;
unsigned long roll;
hrcstamp(&temptime);
roll = 1 << ((sizeof(usc_time_t) * 8) - 1);
usc_MD_rollover_val = (usc_time_t) (roll + roll - 1);
#endif
#if defined(SUN) || defined(HP) || \
defined(BALANCE) || \
defined(RS6000) || defined(IBM3090) || \
defined(NEXT) || defined(TITAN) || defined(GP_1000) || \
defined(KSR) || \
defined(SGI) || defined(FX8)
struct timeval tp;
struct timezone tzp;
unsigned long roll;
gettimeofday(&tp,&tzp);
roll = 1 << ((sizeof(usc_time_t)*8)-1);
roll = roll + roll - 1;
usc_MD_rollover_val = (usc_time_t) (roll / 1000000);
#endif
}
usc_time_t usc_MD_clock()
{
#if defined(TC_2000) || defined(TC_2000_TCMP)
struct
{
unsigned long hi;
unsigned long low;
} usclock;
get64bitclock(&usclock);
return((usc_time_t)usclock.low);
#endif
#if defined(IPSC860)
esize_t hwtime;
unsigned long ustime;
hwclock(&hwtime);
hwtime.shigh = (hwtime.shigh & 0x7) << (sizeof(long)*8-3);
hwtime.slow = ((hwtime.slow >> 3) & ~(0x7 << (sizeof(long)*8-3)))
| hwtime.shigh;
ustime = (unsigned long)hwtime.slow * 0.8;
return( (usc_time_t) ustime);
#endif
#if defined(NCUBE)
unsigned long ustime;
double amicclk();
ustime = (unsigned long) amicclk();
/* printf("usc_MD_clock: returning %lu %u\n",ustime,ustime); */
return( (usc_time_t) ustime);
#endif
#if defined(FX2800) || defined(FX2800_SWITCH)
struct hrcval temptime;
hrcstamp(&temptime);
return ((usc_time_t) (temptime.hv_low * 10));
#endif
#if defined(SUN) || defined(HP) || \
defined(BALANCE) || \
defined(RS6000) || defined(IBM3090) || \
defined(NEXT) || defined(TITAN) || defined(TC1000) || \
defined(KSR) || \
defined(SGI) || defined(FX8)
unsigned long ustime;
struct timeval tp;
struct timezone tzp;
gettimeofday(&tp,&tzp);
ustime = (unsigned long) tp.tv_sec;
ustime = ustime % usc_MD_rollover_val;
ustime = (ustime * 1000000) + (unsigned long) tp.tv_usec;
return((usc_time_t) ustime);
#endif
}